//index.js
//获取应用实例
const app = getApp(),util=require('../../utils/util.js');

Page({
  data: {
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    type:'',
    why:false,
    to:1,
    togo:'',
    content:'',
    jobList:[
      // {id:1,title:'招聘下沙话务员',wages:'120',mode:'日结',time:'5月10日至5月31日',peoplestart:5,peopleend:7,position:'杭州-江干区'},
      // {id:1,title:'招聘下沙话务员',wages:'120',mode:'日结',time:'5月10日至5月31日',peoplestart:5,peopleend:7,position:'杭州-江干区'},
      // {id:1,title:'招聘下沙话务员',wages:'120',mode:'日结',time:'5月10日至5月31日',peoplestart:5,peopleend:7,position:'杭州-江干区'},
      // {id:1,title:'招聘下沙话务员',wages:'120',mode:'日结',time:'5月10日至5月31日',peoplestart:5,peopleend:7,position:'杭州-江干区'},
      // {id:1,title:'招聘下沙话务员',wages:'120',mode:'日结',time:'5月10日至5月31日',peoplestart:5,peopleend:7,position:'杭州-江干区'},
      // {id:1,title:'招聘下沙话务员',wages:'120',mode:'日结',time:'5月10日至5月31日',peoplestart:5,peopleend:7,position:'杭州-江干区'}
    ],
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  onLoad: function () {
    
  },
  onShow(){
    let type = wx.getStorageSync('type')
    if(app.globalData.userInfo == null){
      this.setData({
        why:true,
        content:'请您先登录',
        to:1,
        togo:'登录'
      })
    }
    // else if(type !=2){
    //   this.setData({
    //     why:true,
    //     content:'请先完善个人信息',
    //     to:2,
    //     togo:'完善信息'
    //   })
    // }
    else{
      this.setData({
        why:false,
      })
    }
    this.getJobList()
  },
  onReady(){
    
  },
  cancel(){
    wx.switchTab({
      url: '/pages/my/my',
    })
  },
  loginAgain(){
    if(this.data.to==1){
      wx.switchTab({
        url: '/pages/my/my',
      })
    }else if(this.data.to==2){
      
        wx.navigateTo({
          url: '/pages/authentication/authentication',
        })
     
    }
  },
  getJobList(){
    let that=this;
    wx.request({
      url: app.globalData.url+'standard/achievementList',
      method:'POST',
      success(res){
        console.log(res,'职位列表')
        if(res.statusCode==200 && res.data.code==1){
          that.setData({
            jobList:res.data.data.list
          })
        }
      },
      fail(res){}
    })
  },
  getUserInfo: function(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  }
})
